<?php
/* --------------------------------------------------------------
   products_images_popup.php 2008-04-20 gambio
   Gambio OHG
   http://www.gambio.de
   Copyright (c) 2008 Gambio OHG
   Released under the GNU General Public License (Version 2)
   [http://www.gnu.org/licenses/gpl-2.0.html]
   --------------------------------------------------------------


   based on: 
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
   (c) 2002-2003 osCommerce(popup_image.php,v 1.12 2001/12/12); www.oscommerce.com
   (c) 2004 XT-Commerce - community made shopping http://www.xt-commerce.com ($Id: popup_image.php 859 2005-04-14 18:15:06Z novalis $) 

   Released under the GNU General Public License 
   -----------------------------------------------------------------------------------------
   Third Party contributions:
   Modified by BIA Solutions (www.biasolutions.com) to create a bordered look to the image

   Released under the GNU General Public License 
   ---------------------------------------------------------------------------------------*/

if(defined('_GM_VALID_CALL') === false) die('x0');

require_once (DIR_FS_INC.'xtc_get_products_mo_images.inc.php');

if ((int) $_GET['imgID'] == 0) {
	$products_query = xtc_db_query("select pd.products_name, p.products_image from ".TABLE_PRODUCTS." p left join ".TABLE_PRODUCTS_DESCRIPTION." pd on p.products_id = pd.products_id where p.products_status = '1' and p.products_id = '".(int) $_GET['pID']."' and pd.language_id = '".(int) $_SESSION['languages_id']."'");
	$products_values = xtc_db_fetch_array($products_query);
} else {
	$products_query = xtc_db_query("select pd.products_name, p.products_image, pi.image_name from ".TABLE_PRODUCTS_IMAGES." pi, ".TABLE_PRODUCTS." p left join ".TABLE_PRODUCTS_DESCRIPTION." pd on p.products_id = pd.products_id where p.products_status = '1' and p.products_id = '".(int) $_GET['pID']."' and pi.products_id = '".(int) $_GET['pID']."' and pi.image_nr = '".(int) $_GET['imgID']."' and pd.language_id = '".(int) $_SESSION['languages_id']."'");
	$products_values = xtc_db_fetch_array($products_query);
	$products_values['products_image'] = $products_values['image_name'];
}

// get x and y of the image
$img = DIR_WS_POPUP_IMAGES.$products_values['products_image'];
$size = GetImageSize("$img");

//get data for mo_images
$mo_images = xtc_get_products_mo_images((int) $_GET['pID']);
$img = DIR_WS_THUMBNAIL_IMAGES.$products_values['products_image'];
$osize = GetImageSize("$img");
if ($mo_images != false) {
	//$bwidth = $osize[0];
	$bheight = $osize[1];
	foreach ($mo_images as $mo_img) {
		$img = DIR_WS_THUMBNAIL_IMAGES.$mo_img['image_name'];
		$mo_size = GetImageSize("$img");
		// if ($mo_size[0] > $bwidth)  $bwidth  = $mo_size[0];
		if ($mo_size[1] > $bheight)
			$bheight = $mo_size[1];
	}
	$bheight += 50;
}
?>

<div align="center">
<h1><?php echo $products_values['products_name']; ?></h1>

<p><?php echo xtc_image(DIR_WS_POPUP_IMAGES . $products_values['products_image'], $products_values['products_name'], $size[0], $size[1]); ?></p>

<p><a href="#" onClick="gmLightBox.close_box();return false"><?php echo TEXT_CLOSE_WINDOW ?></a></p>

</div>